package testcase.setting;

import basic.BasicCase;
import org.openqa.selenium.By;
import org.testng.Assert;
import org.testng.annotations.Test;

/**
 * Created by 13714526025 on 2018/9/19.
 * Description：测试设置界面中跳转会员账号中心
 */
public class AppToOppoCenter extends BasicCase {
    @Test
    public void testName() {
        //等待首页设置按钮出现
        finder.waitforWebElement("com.oppo.ohome:id/iv_setting");
        //点击“设置”进入
        driver.findElement(By.id("com.oppo.ohome:id/iv_setting")).click();
        //判断是否出现头像和用户昵称
        Assert.assertTrue(driver.findElement(By.id("com.oppo.ohome:id/user_name")).isDisplayed() && driver.findElement(By.id("com.oppo.ohome:id/iv_avatar")).isDisplayed());
        //获取OPPO账号手机号码并存储到变量中
        String str = driver.findElement(By.id("com.oppo.ohome:id/account_name")).getText();
        //获取app中的用户昵称
        String appUserName = driver.findElement(By.id("com.oppo.ohome:id/user_name")).getText();
        //跳转进入会员账号中心
        driver.findElement(By.id("com.oppo.ohome:id/iv_avatar")).click();
        finder.waitforWebElement("com.oppo.usercenter:id/action_bar_title");
        //获取会员中心的手机号码并存储变量中
        String oppoCenterPhone = driver.findElement(By.id("com.oppo.usercenter:id/tv_account_name")).getText();

        //根据：来分割OPPO账号：137******25，得到137******25
        String phone[] = str.split("\\：");//进行分割
        String appPhone=phone[1];
        //断言app中的手机号码是否相同
        Assert.assertEquals(appPhone, oppoCenterPhone);
    }
}
